//
//  GHtabbarBtn.m
//  12-guhu_weibo
//
//  Created by GHapple on 15-1-31.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "GHtabbarBtn.h"

@interface GHtabbarBtn ()

@end

@implementation GHtabbarBtn
// 设置一些一次性的属性
- (id)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder:aDecoder]) {
        [self setting];
    }
    return  self;
}
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
         [self setting];
    }
    return self;
}
- (void)setting{
//  设置文字和图片居中
    self.imageView.contentMode = UIViewContentModeCenter;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
//    设置字体颜色和大小
    self.titleLabel.font = [UIFont systemFontOfSize:12];
    [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self setTitleColor:[UIColor orangeColor] forState:UIControlStateSelected];
    
}
- (void)setItem:(UITabBarItem *)item{

    _item = item;
    
    [self setTitle:item.title forState:UIControlStateNormal];
    [self setImage:item.image forState:UIControlStateNormal];
    [self setImage:item.selectedImage forState:UIControlStateSelected];
}
// 取消高亮状态
- (void)setHighlighted:(BOOL)highlighted{
    
}
// 重新定义图片位置
- (CGRect)imageRectForContentRect:(CGRect)contentRect{
    CGFloat imageX =  0;
    CGFloat imageY = 0;
    CGFloat imageW =contentRect.size.width;
    CGFloat imageXH = contentRect.size.height * 0.6;
    return  CGRectMake(imageX , imageY,imageW, imageXH);
    }
// 重新文字定义位置
- (CGRect)titleRectForContentRect:(CGRect)contentRect{
    CGFloat titleX = 0 ;
    CGFloat titleY = contentRect.size.height* 0.6;
    CGFloat titleW = contentRect.size.width ;
    CGFloat titleH = contentRect.size.height - contentRect.size.height * 0.6 ;
    return  CGRectMake(titleX, titleY, titleW, titleH);
}
@end
